﻿using System;

namespace Affinity.Flux
{
    /// <summary>
    /// A pairing between an inlet and an outlet.
    /// </summary>
    public abstract class Pairing : IDisposable
    {
        /// <summary>
        /// Constructor accepting the inlet and outlet that are being paired.
        /// </summary>
        /// <param name="inlet"></param>
        /// <param name="outlet"></param>
        protected Pairing(Outlet outlet, Inlet inlet)
        {
            if (inlet == null) throw new ArgumentNullException("inlet");
            if (outlet == null) throw new ArgumentNullException("outlet");

            _inlet = inlet;
            _outlet = outlet;
        }

        /// <summary>
        /// Gets the contract value.
        /// </summary>
        public object Contract
        {
            get { return Outlet.Contract; }
        }

        /// <summary>
        /// Gets the inlet.
        /// </summary>
        public Inlet Inlet
        {
            get { return _inlet; }
        }

        /// <summary>
        /// Gets the outlet.
        /// </summary>
        public Outlet Outlet
        {
            get { return _outlet; }
        }

        /// <summary>
        /// Disposes this object.
        /// </summary>
        public abstract void Dispose();

        private readonly Inlet _inlet;
        private readonly Outlet _outlet;
    }
}
